﻿CREATE PROCEDURE [dbo].[DbDeploy]
AS
BEGIN
	DECLARE @sql NVARCHAR(4000)

	SET @sql = 'EXEC sp_configure ''clr enable'', 1;'
	EXEC sp_executesql @sql

	DECLARE @dbName NVARCHAR(4000)
	SELECT @dbName = DB_NAME();	

	SET @sql = 'USE '+ @dbName +'; EXEC sp_changedbowner ''sa'';'
	EXEC sp_executesql @sql

	SET @sql = 'ALTER DATABASE ' + @dbName + ' SET TRUSTWORTHY ON'
	EXEC sp_executesql @sql	

	RETURN 1
END